package com.fenyin.samples.study.jdk.datastruct.queue;  

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
  
public class QueueTest {
	
	private static final Log log = LogFactory.getLog(QueueTest.class);
	
	private static void arrayCycleQueueTest(){
		ArrayCycleQueue<String> queue = new ArrayCycleQueue<String>(5);
		queue.enqueue("fzc1");
		queue.enqueue("fzc2");
		queue.enqueue("fzc3");
		queue.enqueue("fzc4");
		queue.enqueue("fzc5");
		log.info("enqueue-5:"+queue.display());
		queue.dequeue();
		queue.dequeue();
		log.info("dequeue-2:"+queue.display());
		queue.enqueue("fzc6");
		queue.enqueue("fzc7");
		log.info("enqueue-2:"+queue.display());
		queue.dequeue();
		queue.dequeue();
		queue.dequeue();
		log.info("dequeue-3:"+queue.display());
	}
	
	private static void linkedQueueTest(){
		LinkedQueue<String> queue = new LinkedQueue<String>();
		queue.enqueue("fzc1");
		queue.enqueue("fzc2");
		queue.enqueue("fzc3");
		queue.enqueue("fzc4");
		queue.enqueue("fzc5");
		log.info("enqueue-5:"+queue.display());
		queue.dequeue();
		queue.dequeue();
		log.info("dequeue-2:"+queue.display());
		queue.enqueue("fzc6");
		queue.enqueue("fzc7");
		log.info("enqueue-2:"+queue.display());
		queue.dequeue();
		queue.dequeue();
		queue.dequeue();
		log.info("dequeue-3:"+queue.display());
	}
	
	public static void main(String[] args){
//		arrayCycleQueueTest();
		linkedQueueTest();
	}
}
